﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace IVRJunctionUI
{
    public partial class ContentModerationChannel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected bool Antonym(Object value)
        {
            bool status = (Boolean)value;

            return !status;
        }


        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = GridView1.Rows[e.RowIndex];
    
            CheckBox checkBox = (CheckBox)GridView1.Rows[e.RowIndex].Cells[5].FindControl("CheckBox1");

            bool isPrivate = !checkBox.Checked;

            Label recordingFileLocation = (Label)GridView1.Rows[e.RowIndex].Cells[5].FindControl("Label1");
            TextBox dateTime = (TextBox)GridView1.Rows[e.RowIndex].Cells[5].FindControl("TextBox2");
            TextBox phoneNumber = (TextBox)GridView1.Rows[e.RowIndex].Cells[5].FindControl("TextBox1");

            try
            {
                DateTime dateTimeNow = Convert.ToDateTime(dateTime.Text);
                DatabaseLayer.DatabaseFunctions objectDatabaseFunctions = new DatabaseLayer.DatabaseFunctions();
                bool isUpdateSuccess = objectDatabaseFunctions.updateDataGridRow(recordingFileLocation.Text, isPrivate, phoneNumber.Text, dateTimeNow);
                if (isUpdateSuccess)
                    GridView1.EditIndex = -1;
            }
            catch (Exception generalException)
            {

            }
            finally
            {
                e.Cancel = true;
                GridView1.DataBind();
            }
        }
    
    }
}